package com.guijianpan.system.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.guijianpan.framework.domain.BaseDomain;

/**
 * 系统菜单表
 * 
 * @author yzChen
 */
@Entity
@Table(name = "T_MENU")
public class Menu extends BaseDomain {

	private static final long serialVersionUID = -4088543778891538921L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "ID")
	private Long id;

	@Column(name = "NAME")
	private String name;

	@Column(name = "ICON")
	private String icon;

	@Column(name = "URL")
	private String url;

	@Column(name = "PANEL")
	private String panel;
	
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "PID")
	private Menu parentMenu;
	
	@OneToMany(fetch=FetchType.LAZY)
	@JoinTable(name="T_MENU", joinColumns={@JoinColumn(name="PID")}, inverseJoinColumns={@JoinColumn(name="ID")})
	private List<Menu> childMenus;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Menu getParentMenu() {
		return parentMenu;
	}

	public void setParentMenu(Menu parentMenu) {
		this.parentMenu = parentMenu;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getPanel() {
		return panel;
	}

	public void setPanel(String panel) {
		this.panel = panel;
	}

	public List<Menu> getChildMenus() {
		return childMenus;
	}

	public void setChildMenus(List<Menu> childMenus) {
		this.childMenus = childMenus;
	}


	@Transient
	private Boolean userHasRight = false;

	public void setUserHasRight(Boolean hasRight) {
		this.userHasRight = hasRight;
	}

	public Boolean getUserHasRight() {
		return this.userHasRight;
	}

}
